package com.hua.Thread.ThreadPool1;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author: _hua
 * @created: 2019/3/10.
 * @updater:
 * @description:
 */
public class CacheThreadPoolExecutorTest {
    public static void main(String[]  args ) {
        ExecutorService cacheThreadPool = Executors.newCachedThreadPool();
        for(int i =1;i<=5;i++){
            final int index=i ;
            try{
                Thread.sleep(1000);
            }catch(InterruptedException  e ) {
                e.printStackTrace();
            }
            cacheThreadPool.execute(new Runnable(){
                @Override
                public void run() {
                    System.out.println("第" +index +"个线程" +Thread.currentThread().getName());
                }
            });
        }
        //System.out.println(cacheThreadPool);
    }

}
